/*
	Chris Butler
	CSC160-001
	gradeIPO
	Description: Given information (average score on exams, prjts, and part) about
		the student's grade, calculate his final grade	
	*/

#include <iostream>
#include <fstream>
#include <string>
#include <ostream>
#include <iomanip>

using namespace std;

const double EXAM_WEIGHT = .3;
const double PRJT_WEIGHT = .6;
const double PART_WEIGHT = .1;

int main(int argc, char** argv)
{
	ifstream ifile;
	ofstream ofile;
	
	ifile.open("grades.dat");
	
	string dataLabels;

//skip past the labels at top of page	
	ifile >> dataLabels
		>> dataLabels
		>> dataLabels;

	double finalGrade = 0;
	double examGrade = 0;
	double prjtGrade = 0;
	double partGrade = 0;

	ifile >> examGrade
		>> prjtGrade
		>> partGrade;

	ifile.close();
/*
	cout << "Grade IPO:" << endl;
	cout << "Enter the average grade for:" << endl;
	
	cout << "\texams: ";
	cin >> examGrade;
	
	cout << "\tprojects: ";
	cin >> prjtGrade;
	
	cout << "\tparticipation: ";
	cin >> partGrade;

*/

	finalGrade = (EXAM_WEIGHT * examGrade)
				+ (PRJT_WEIGHT * prjtGrade)
				+ (PART_WEIGHT * partGrade);
	
	ofile.open("finalGrade.dat", ios_base::app);
	
	ofile << fixed << showpoint << setprecision(2);
	ofile << "Final Grade: " << finalGrade << "\n";
	ofile.close();

	ofile.open("grades.dat", ios_base::app);

	ofile << fixed << showpoint << setprecision(2);
	ofile << "\t" << finalGrade << "\n";
	ofile.close();

#ifdef _WIN32
	#include <stdlib.h>
	system("pause");
#endif	
	return 0;
}
